{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Winsorizer\n",
    "Winzorizer finds maximum and minimum values following a Gaussian or skewed distribution as indicated. It can also cap the right, left or both ends of the distribution.\n",
    "\n",
    "The Winsorizer() caps maximum and / or minimum values of a variable.\n",
    "\n",
    "The Winsorizer() works only with numerical variables. A list of variables can\n",
    "be indicated. Alternatively, the Winsorizer() will select all numerical\n",
    "variables in the train set.\n",
    "\n",
    "The Winsorizer() first calculates the capping values at the end of the\n",
    "distribution. The values are determined using:\n",
    "\n",
    "- a Gaussian approximation,\n",
    "- the inter-quantile range proximity rule (IQR)\n",
    "- percentiles.\n",
    "\n",
    "\n",
    "### Example"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# importing libraries\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "from feature_engine.outliers import Winsorizer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load titanic dataset from OpenML\n",
    "\n",
    "def load_titanic():\n",
    "    data = pd.read_csv(\n",
    "        'https://www.openml.org/data/get_csv/16826755/phpMYEkMl')\n",
    "    data = data.replace('?', np.nan)\n",
    "    data['cabin'] = data['cabin'].astype(str).str[0]\n",
    "    data['pclass'] = data['pclass'].astype('O')\n",
    "    data['embarked'].fillna('C', inplace=True)\n",
    "    data['fare'] = data['fare'].astype('float')\n",
    "    data['fare'].fillna(data['fare'].median(), inplace=True)\n",
    "    data['age'] = data['age'].astype('float')\n",
    "    data['age'].fillna(data['age'].median(), inplace=True)\n",
    "    data.drop(['name', 'ticket'], axis=1, inplace=True)\n",
    "    return data\n",
    "\n",
    "# To plot histogram of given numerical feature\n",
    "\n",
    "\n",
    "def plot_hist(data, col):\n",
    "    plt.figure(figsize=(8, 5))\n",
    "    plt.hist(data[col], bins=30)\n",
    "    plt.title(\"Distribution of \"+col)\n",
    "    return plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>pclass</th>\n",
       "      <th>survived</th>\n",
       "      <th>sex</th>\n",
       "      <th>age</th>\n",
       "      <th>sibsp</th>\n",
       "      <th>parch</th>\n",
       "      <th>fare</th>\n",
       "      <th>cabin</th>\n",
       "      <th>embarked</th>\n",
       "      <th>boat</th>\n",
       "      <th>body</th>\n",
       "      <th>home.dest</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>157</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>male</td>\n",
       "      <td>28.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>51.8625</td>\n",
       "      <td>E</td>\n",
       "      <td>S</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Brighton, MA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>400</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>female</td>\n",
       "      <td>34.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>32.5000</td>\n",
       "      <td>n</td>\n",
       "      <td>S</td>\n",
       "      <td>10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Greenport, NY</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>546</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>female</td>\n",
       "      <td>28.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>13.0000</td>\n",
       "      <td>n</td>\n",
       "      <td>S</td>\n",
       "      <td>9</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Spain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>618</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>male</td>\n",
       "      <td>35.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8.0500</td>\n",
       "      <td>n</td>\n",
       "      <td>S</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Lower Clapton, Middlesex or Erdington, Birmingham</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1208</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>female</td>\n",
       "      <td>9.0</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>27.9000</td>\n",
       "      <td>n</td>\n",
       "      <td>S</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     pclass  survived     sex   age  sibsp  parch     fare cabin embarked  \\\n",
       "157       1         0    male  28.0      0      0  51.8625     E        S   \n",
       "400       2         1  female  34.0      1      1  32.5000     n        S   \n",
       "546       2         1  female  28.0      0      0  13.0000     n        S   \n",
       "618       3         0    male  35.0      0      0   8.0500     n        S   \n",
       "1208      3         0  female   9.0      3      2  27.9000     n        S   \n",
       "\n",
       "     boat body                                          home.dest  \n",
       "157   NaN  NaN                                       Brighton, MA  \n",
       "400    10  NaN                                      Greenport, NY  \n",
       "546     9  NaN                                              Spain  \n",
       "618   NaN  NaN  Lower Clapton, Middlesex or Erdington, Birmingham  \n",
       "1208  NaN  NaN                                                NaN  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Loading titanic dataset\n",
    "data = load_titanic()\n",
    "data.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "train data: (916, 11)\n",
      "test data: (393, 11)\n"
     ]
    }
   ],
   "source": [
    "# let's separate into training and testing set\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(data.drop('survived', axis=1),\n",
    "                                                    data['survived'],\n",
    "                                                    test_size=0.3,\n",
    "                                                    random_state=0)\n",
    "\n",
    "print(\"train data:\", X_train.shape)\n",
    "print(\"test data:\", X_test.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Max age: 80.0\n",
      "Max fare: 512.3292\n"
     ]
    }
   ],
   "source": [
    "# let's find out the maximum Age and maximum Fare in the titanic\n",
    "\n",
    "print(\"Max age:\", data.age.max())\n",
    "print(\"Max fare:\", data.fare.max())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAeYAAAE/CAYAAACTomAoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAZM0lEQVR4nO3de7SldX3f8fdHhoAC4SKndJwBBpVqiKsOdkRc2gRBI+AFs1ZicHmZWLImbTHRhCSCGsUuabGNktomtEQQvCHESyBIjIhkGdsKDgjIReIEBplxYAaQmxgi+O0f+zeyHWY49zm/vef9Wmuv8+zfc/v+ztn7fM7ze579nFQVkiSpD09Z6AIkSdLjDGZJkjpiMEuS1BGDWZKkjh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W36TmC/hSxmJpIsAw4FrmRE+9OGf68FNgKXAf8I3FdVj7ZFRuW19qfAHwE/ac+fzmj2A6CALye5ut1FEEbz9XUQsAn4WDvF8NEkuzGafRl2PHB+mx65vlTVeuBPgO8BG4D7gavZTu+XcQrmsVaDP9FG6hL6JLsDnwPeUVUPDM8bpf5U1WM1GJ5byuAftDx3YSuaviSvBjZW1dULXcsceWlVvYDBqasTk/zS8MwRen0tAl4AnFlVhwI/ZIuh3hHqCwDtvOtrgb/cct6o9KWdBz+OwR9OzwB244mnGufNOAXzpLcBHUF3JVkM0L5uXOB6pizJzgxC+VNV9fnWPLL9Aaiq+4ArGAxh7ZVk830ARuG19hLgtUnWMvhvb0cyOLc5av0AfnpEQ1VtZHAe8zBG8/W1DlhXVVe2559lENSj2JfNjgGuqaq72vNR7MvLgduqalNV/Rj4PIP30HZ5v4xTMI/jbUAvBla26ZUMztV2L0mAs4Gbq+rDQ7NGrj9JJpLs1aafyuBc+c0MAvrX2mLd96WqTqmqpVW1jMF746tV9UZGrB8ASXZLssfmaQbnM29gBF9fVXUncEeS57Smo4CbGMG+DHkDjw9jw2j25XvA4Ume1n6fbf65bJ/3y0KfZJ/jE/bHAv/A4Bzguxe6nmnWfj6Dcxk/ZvBX9AkMzgFeDnwX+Aqwz0LXOcW+vJTBcNX1wLXtcewo9gf418C3Wl9uAN7b2p8JXAWsYTBkt8tC1zqNPh0BXDKq/Wg1X9ceN25+r4/i66vVvRxY3V5jfwXsPcJ92Q24B9hzqG1U+/J+4Dvtff8JYJft9X7xzl+SJHVknIayJUkaeQazJEkdMZglSeqIwSxJUkcMZkmSOmIwS5LUEYNZkqSOGMySJHXk/wOn1so1cVz37wAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 576x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Histogram of age feature before capping outliers\n",
    "plot_hist(data, 'age')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAeYAAAE/CAYAAACTomAoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAYCElEQVR4nO3dfbTdVZ3f8fdHAjLjA+HhmsUkgeCQ6jBdFWlq49KpSkbLgzX84TC4HIk0s9LVUqvVWU58GKtdtsV2KSN9oGWJNfiMzFgySh1jwOXMWgMaFJAHlSsFkxhIRAgCoyP67R9nXz3EhHvuzb3J5uT9Wuuss39779/vt88ml09++/e7J6kqJElSH55ysAcgSZJ+yWCWJKkjBrMkSR0xmCVJ6ojBLElSRwxmSZI6YjBLcyDJ/0zyJ3N0rBOSPJzksLb95SR/OBfHbsf7v0nWzNXxZnDe9yb5QZJ799H+L5Pc1z77sQd6fFIv4u8xS08syd3AIuAx4GfA7cAVwGVV9fNZHOsPq+pLM9jny8DHqupDMzlX2/fdwMlV9Qcz3XcuJTkB+DZwYlXt3Ev74cBDwMqquvlAj0/qiVfM0mj+WVU9AzgRuAj4Y+DyuT5JkgVzfcxOnADcv7dQbhYBRwK3zebgYzxvOgQZzNIMVNXuqtoI/D6wJsnfB0jykSTvbeXjknwuyYNJfpjkr5I8JclHGQTUX7Tl2rcmWZakkqxN8j3g2qG64bD5zSRfTfJQkquTHNPO9dIk24bHmOTuJL+b5Azg7cDvt/Pd3Np/sTTexvXOJPck2ZnkiiRHtbapcaxJ8r22DP2Ofc1NkqPa/rva8d7Zjv+7wCbgN9o4PrLHfn+PwdU0wINJrm31H0yytX3mG5P8ztA+705yVZKPJXkIeH07/+VJdiTZ3pbODxv9v67UB4NZmoWq+iqwDfidvTS/pbVNMLgSfPtgl3od8D0GV99Pr6r/PLTPS4DfAv7pPk55PvDPgeMZLKlfMsIYvwD8R+DT7XzP20u317fXy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DiqjoZeABY2/qvBR5o9Re3foe6NwJ3DG07dzPzsqo6dehXo7r9uR2rYGbo60Cr6u+Aqa8DVVNVXwF+uEf1amBDK28Azhmqv6IGrgcWJjn+gAy0Q1W1o6q+3so/YvA/ycU4f9Nqc/Bw2zy8vQo4Hbiq1e85d1NzehWwKkkOzGj7k2QJcDbwobYdnLv91e3P7bgF896+DnTxQRrLk8miqtrRyvcCi1rZ+dyHtjz4fOAGnL+RtKXYm4CdwCbgu8CDVfVY6zI8P7+Yu9a+Gzj2gA64L38KvBX4eds+FuduJgr4YpIb27dOQsc/t/57zHqcqqokPqr/BJI8Hfgz4E1V9dDwxYjzt29V9TPg1CQLgc8Czz24I3pySPJKYGdV3ZjkpQd5OE9WL66q7UmeBWxK8q3hxt5+bsftinmkrwPVr7hvaqmmve9s9c7nHpIcziCUP15Vf96qnb8ZqKoHgeuAFzJYJpy6QBien1/MXWs/Crj/wI60Gy8CXpXkbga3504HPohzN7Kq2t7edzL4S+EL6PjndtyC2a8DnZ2NwJpWXgNcPVR/fntKcSWwe2jp55DT7tNdDtxRVR8YanL+ppFkol0pk+TXgJczuEd/HfDq1m3PuZua01cD19Yh+qULVfW2qlpSVcsY/D/t2qp6Lc7dSJI8LckzpsrAK4Bb6fnntqrG6gWcBXyHwf2rdxzs8fT2Aj4J7AB+yuDeyVoG9582A3cCXwKOaX3D4Cn37wLfBFYc7PEf5Ll7MYN7VbcAN7XXWc7fSHP3D4BvtLm7FXhXq3828FVgEvgM8NRWf2Tbnmztzz7Yn6GHF/BS4HPO3Yzm7NnAze1121Qu9Pxz6zd/SZLUkXFbypYk6UnNYJYkqSMGsyRJHTGYJUnqiMEsSVJHDGZJkjpiMEuS1BGDWZKkjvx/csKUYAcL4/kAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 576x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Histogram of fare feature before capping outliers\n",
    "plot_hist(data, 'fare')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Capping : Gaussian\n",
    "\n",
    "Gaussian limits:\n",
    "+ right tail: mean + 3* std\n",
    "+ left tail: mean - 3* std\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Winsorizer(variables=['age', 'fare'])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''Parameters\n",
    "----------\n",
    "capping_method : str, default=gaussian\n",
    "\n",
    "    Desired capping method. Can take 'gaussian', 'iqr' or 'quantiles'.\n",
    "\n",
    "tail : str, default=right\n",
    "\n",
    "    Whether to cap outliers on the right, left or both tails of the distribution.\n",
    "    Can take 'left', 'right' or 'both'.\n",
    "\n",
    "fold: int or float, default=3\n",
    "\n",
    "    How far out to to place the capping values. The number that will multiply\n",
    "    the std or IQR to calculate the capping values. Recommended values, 2\n",
    "    or 3 for the gaussian approximation, or 1.5 or 3 for the IQR proximity\n",
    "    rule.\n",
    "\n",
    "variables: list, default=None\n",
    "  \n",
    "missing_values: string, default='raise'\n",
    "\n",
    "    Indicates if missing values should be ignored or raised.\n",
    "'''\n",
    "# capping at right tail using gaussian capping method\n",
    "capper = Winsorizer(\n",
    "    capping_method='gaussian', tail='right', fold=3, variables=['age', 'fare'])\n",
    "\n",
    "# fitting winsorizer object to training data\n",
    "capper.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'age': 67.49048447470315, 'fare': 174.78162171790441}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# here we can find the maximum caps allowed\n",
    "capper.right_tail_caps_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# this dictionary is empty, because we selected only right tail\n",
    "capper.left_tail_caps_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAecAAAE/CAYAAAB8YAsWAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAU40lEQVR4nO3dffRlVV3H8fcHRjPFBJxpGoFhUGdZ1Eq00XBlhWKJ+ICtVYTLh4loTauotLACsyCXFNZSy0qTFMEnhHwIUjJxsoVWSoOKIkhOOMiMMDOAPAimDn774+6fXMYZfs/89u/83q+17rrn7PO097135nP3PueeX6oKSZLUj30WugKSJOm+DGdJkjpjOEuS1BnDWZKkzhjOkiR1xnCWJKkzhrM0B5L8fZI/nqN9rU7y9ST7tvl/T/Jrc7Hvtr9/SbJ+rvY3jeO+OsnNSW56oI8tLTbxd87S/UuyBVgJ7ALuAa4G3g6cXVXfmcG+fq2qPjqNbf4deGdVvWU6x2rbngE8tqpeNN1t51KS1cC1wKFVtWMh6yItBvacpal5blU9HDgUOAv4Q+Ctc32QJMvmep+dWA3cYjBLU2M4S9NQVbdX1cXALwPrk/wYQJJzk7y6TS9P8sEktyW5NcnHk+yT5B2MQuqf27D1HyRZk6SSnJTkK8C/jZWNB/Vjklye5I4kFyU5sB3rqCRbx+uYZEuSZyQ5BngF8MvteFe25d8dJm/1emWS65PsSPL2JI9oyybqsT7JV9qQ9B/t7bVJ8oi2/c62v1e2/T8DuBR4VKvHuXvY9oD2mu1M8rU2ffDY8sOSXJbkziQfTfJ3Sd45tvzIJP/ZXvMrkxw1xbdU6pLhLM1AVV0ObAV+eg+LT2nLVjAaDn/FaJN6MfAVRr3w/arqL8a2+VngR4Bn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I6YzhLktSZ/wcOz6e6KfYedQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 576x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# # Histogram of age feature after capping outliers\n",
    "plot_hist(capper.transform(X_train), 'age')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(67.49048447470315, 174.78162171790441)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# transforming the training and testing data\n",
    "train_t = capper.transform(X_train)\n",
    "test_t = capper.transform(X_test)\n",
    "\n",
    "# let's check the new maximum Age and maximum Fare in the titanic\n",
    "train_t.age.max(), train_t.fare.max()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Gaussian approximation capping, both tails"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Winsorizer(fold=2, tail='both', variables=['fare'])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Capping the outliers at both tails using gaussian capping method\n",
    "\n",
    "winsor = Winsorizer(capping_method='gaussian',\n",
    "                    tail='both', fold=2, variables='fare')\n",
    "winsor.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Minimum caps : {'fare': -62.30099726608475}\n",
      "Maximum caps : {'fare': 127.36509792110658}\n"
     ]
    }
   ],
   "source": [
    "print(\"Minimum caps :\", winsor.left_tail_caps_)\n",
    "\n",
    "print(\"Maximum caps :\", winsor.right_tail_caps_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGg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TW49X7sbr9P8lJgR1Vdv9i1LJIlwHOBC6vqBOD77HHaelz3PUC7lrqGwT8oTwUO5idPdU6Ucd7fjyXJWxhc1vvgYteyEMYtmKd9FOg4SnIgg1D+YFV9vDXfu/u0Vfu6Y7HqG6HnAS9LsoXBZYsXMbjmurSd2oTx/hnYCmytquva+BUMgnoS9j3Ai4E7qmpnVf0I+DiDn4lJ2f+77W1/T8TfwySvAV4KvLIeff/vft33cQvmiXsUaLumejFwa1WdPzRpI7CuDa8DrtzXtY1aVZ1TVUdW1UoG+/pzVfVK4Frg19psY9l3gKq6B7g7yc+1ppOBW5iAfd/cBZyU5Int92B3/ydi/w/Z2/7eCLy63Z19EvDg0CnvsZDkFAaXsl5WVT8YmrQRWJvkoCTHMrgB7kuLUeOcVNVYvYDTGNyd9y3gLYtdzz7o7/MZnLq6EbihvU5jcK31GuCbwGeBwxa71hF/H14IfLINP43BL+Fm4KPAQYtd3wj7fTywqe3/vwQOnaR9D7wd+DpwE/B+4KBx3v/AhxlcT/8RgzMmZ+5tfwNh8C6VbwFfY3D3+qL3YYH7vpnBteTdf/v+fGj+t7S+3wacutj1z+blk78kSerIuJ3KliRpv2YwS5LUEYNZkqSOGMySJHXEYJYkqSMGsyRJHTGYJUnqiMEsSVJH/j/TlylrumqxfgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 576x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Histogram of fare feature after capping outliers\n",
    "plot_hist(winsor.transform(X_train), 'fare')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Max fare: 127.36509792110658\n",
      "Min fare: 0.0\n"
     ]
    }
   ],
   "source": [
    "# transforming the training and testing data\n",
    "train_t = winsor.transform(X_train)\n",
    "test_t = winsor.transform(X_test)\n",
    "\n",
    "print(\"Max fare:\", train_t.fare.max())\n",
    "print(\"Min fare:\", train_t.fare.min())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Inter Quartile Range, both tails\n",
    "**IQR limits:**\n",
    "\n",
    "- right tail: 75th quantile + 3* IQR\n",
    "- left tail:  25th quantile - 3* IQR\n",
    "\n",
    "where IQR is the inter-quartile range: 75th quantile - 25th quantile.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Winsorizer(capping_method='iqr', tail='both', variables=['age', 'fare'])"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# capping at both tails using iqr capping method\n",
    "winsor = Winsorizer(capping_method='iqr', tail='both',\n",
    "                    variables=['age', 'fare'])\n",
    "\n",
    "winsor.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'age': -13.0, 'fare': -62.24179999999999}"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "winsor.left_tail_caps_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'age': 71.0, 'fare': 101.4126}"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "winsor.right_tail_caps_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Max fare: 101.4126\n",
      "Min fare 0.0\n"
     ]
    }
   ],
   "source": [
    "# transforming the training and testing data\n",
    "\n",
    "train_t = winsor.transform(X_train)\n",
    "test_t = winsor.transform(X_test)\n",
    "\n",
    "print(\"Max fare:\", train_t.fare.max())\n",
    "print(\"Min fare\", train_t.fare.min())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### percentiles or quantiles:\n",
    "\n",
    "- right tail: 98th percentile\n",
    "- left tail:  2nd percentile"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Winsorizer(capping_method='quantiles', fold=0.02, tail='both',\n",
       "           variables=['age', 'fare'])"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# capping at both tails using quantiles capping method\n",
    "winsor = Winsorizer(capping_method='quantiles', tail='both',\n",
    "                    fold=0.02, variables=['age', 'fare'])\n",
    "\n",
    "winsor.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Minimum caps : {'age': 2.0, 'fare': 6.44125}\n",
      "Maximum caps : {'age': 61.69999999999993, 'fare': 211.5}\n"
     ]
    }
   ],
   "source": [
    "print(\"Minimum caps :\", winsor.left_tail_caps_)\n",
    "\n",
    "print(\"Maximum caps :\", winsor.right_tail_caps_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Max age: 61.69999999999993\n",
      "Min age 2.0\n"
     ]
    }
   ],
   "source": [
    "# transforming the training and testing data\n",
    "train_t = winsor.transform(X_train)\n",
    "test_t = winsor.transform(X_test)\n",
    "\n",
    "print(\"Max age:\", train_t.age.max())\n",
    "print(\"Min age\", train_t.age.min())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAeYAAAE/CAYAAACTomAoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6A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r4aJJbhictwuR+Xk4AdgF/OVzquDTJU2jaH12DWTNQo1vqJ+q2+iSHAx8AfrWqvjG+btL6o6oeraqTGD1Z7/nADy1tRUsnySuAnVV1y1LX0sgLq+q5jC4JnpvkReMrJ+zzcijwXOAdVfUc4GH2mrbu1B9dg3naR3pOsB1JjgEYXncucT0HTJLDGIXyX1XVB4fmie2PKcOU3I3AC4Ajk0w9n2CSPjc/BvxMki2MLn29hNE1xUntD6pq2/C6E/gQo1/eJvXzshXYWlWfGt6/n1FQt+yPrsHsIz3371pgw7C8AbhmCWs5YIbrhZcBd1TV28ZWTWp/rExy5LD8/cBPMbrufiPws8NmE9MfVfWmqjq2qtYy+v/F31fVa5jQ/kjylCRHTC0DPw3cxoR+XqrqHuDuJD84NJ0K3E7T/mj7gJEkpzO6ZjT1SM+LlraiAy/Je4FTGP0LKDuAC4C/Aa4G1gB3AWdW1d43iC07SV4IfBz4PI9dQ3wzo+vMk9gfP8roZpVDGP2CfXVV/W6SZzAaMR4NfAZ4bVV9a+kqPfCSnAK8sapeMan9Mfy5PzS8PRR4T1VdlORpTODnBSDJSYxuDHwicCdwNsNnh2b90TaYJUmaRF2nsiVJmkgGsyRJjRjMkiQ1YjBLktSIwSxJUiMGsyRJjRjMkiQ1YjBLktTI/we5s3I9U0QETQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 576x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Histogram of age feature after capping outliers\n",
    "plot_hist(train_t, 'age')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
